#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int main()
{
  int x, yA, yB, c, d, randomPlayer, randomHandCount, randomDeckCount, randomNum;
  struct gameState newGameA, newGameB;

  printf("Now Testing: adventurer Card\n");

  SelectStream(1);
  PutSeed((long)14);

  for(x = 0; x < 10; x++){
    
    //Make two identical games A and B.
    for (yA = 0; yA < sizeof(struct gameState); yA++){
      ((char*)&newGameA)[yA] = 0;
    }
    for (yB = 0; yB < sizeof(struct gameState); yB++){
      ((char*)&newGameB)[yB] = 0;
    }
    randomPlayer = Random() * MAX_PLAYERS;
    randomHandCount = Random() * MAX_HAND;
    randomDeckCount =  Random() * MAX_DECK;
    newGameA.whoseTurn = newGameB.whoseTurn = randomPlayer;
    newGameA.handCount[randomPlayer] = newGameB.handCount[randomPlayer] = randomHandCount;
    newGameA.deckCount[randomPlayer] = newGameB.deckCount[randomPlayer] = randomDeckCount;
    newGameA.discardCount[randomPlayer] = newGameB.discardCount[randomPlayer] = Random() * MAX_PLAYERS;
    for(c = 0; c < randomHandCount; c++){
      newGameA.hand[randomPlayer][c] = newGameB.hand[randomPlayer][c] = Random() * 27;
    }
    for(d = 0; d < randomDeckCount; d++){
      newGameA.deck[randomPlayer][d] = newGameB.deck[randomPlayer][d] = Random() * 27;
    }
    
    // Play Card: Adventurer
    newGameA.hand[randomPlayer][c] = newGameB.hand[randomPlayer][c] = adventurer;
    newGameA.handCount[randomPlayer]++;
    newGameB.handCount[randomPlayer]++;
    randomNum = Random() * 3; 
    cardEffect(adventurer, randomNum, 0, 0, &newGameA, randomHandCount, NULL);
    
    //Compare game A and B. ( +2 cards, deckCount A < B)
    //printf("hand	A: %d		B: %d\n", newGameA.handCount[randomPlayer], newGameB.handCount[randomPlayer]);
    assert(newGameA.handCount[randomPlayer] == newGameB.handCount[randomPlayer] + 2);
    assert(newGameA.deckCount[randomPlayer] < newGameB.deckCount[randomPlayer]);
  }
  
  printf("Everything checks out according to this test.");

  return 0;
}

